<?php

/**
 * login actions.
 *
 * @package    playcafebookings
 * @subpackage login
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class loginActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    sfContext::getInstance()->getConfiguration()->loadHelpers(array('PlayCafeConfig'));
    
    $this->getUser()->setAuthenticated(false);
    
    if ($request->isMethod(sfRequest::POST)) {
        $logins = config('logins');
        
        foreach ($logins as $login) {
            if ($request->getParameter('username') == $login['username']
                && $request->getParameter('password') == $login['password']
            ) {
                $this->getUser()->setAuthenticated(true);
                $this->redirect('bookings/index');
                return;
            }
        }
        
        $this->getUser()->setFlash('error', 'Sorry, your login attempt failed!');
    }
    
    // Show the login form
  }
}
